package me.leon.ext.android

import android.widget.TextView
import androidx.annotation.DrawableRes

/**
 * @author : Leon Shih
 * @time : 2019/12/16 0016 18:10
 * @e-mail : deadogone@gmail.com
 * @desc : TextView Extension
 */
fun TextView.drawableLeft(@DrawableRes resId: Int) =
    this.setCompoundDrawables(
        drawableRes(resId)?.apply { setBounds(0, 0, minimumWidth, minimumHeight) },
        null,
        null,
        null
    )

fun TextView.drawableRight(@DrawableRes resId: Int) =
    this.setCompoundDrawables(
        null,
        null,
        drawableRes(resId)?.apply { setBounds(0, 0, minimumWidth, minimumHeight) },
        null
    )

fun TextView.drawableTop(@DrawableRes resId: Int) =
    this.setCompoundDrawables(
        null,
        drawableRes(resId)?.apply { setBounds(0, 0, minimumWidth, minimumHeight) },
        null,
        null
    )

fun TextView.drawableBottom(@DrawableRes resId: Int) =
    this.setCompoundDrawables(
        null,
        null,
        null,
        drawableRes(resId)?.apply { setBounds(0, 0, minimumWidth, minimumHeight) }
    )
